﻿using System;
using System.Data.SqlClient;
using System.Web.UI;

namespace 上课演示
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlConnection connection;

            string connectionString = "server=.;database=schooldb;Trusted_Connection=SSPI";
            try
            {
                connection = new SqlConnection(connectionString);
                connection.Open();
                connection.Close();
                connection.Open();
                Response.Write(connection.State);
            }
            catch (Exception exception)
            {
                Response.Write(exception.Message);
            }
        }
    }
}